let App = getApp()
Page({
  data: {
    title: '',
    content: ''
  },
  onLoad() {
    let userId = wx.getStorageSync("userId");
    this.setData({ userId: userId })
  },
  bindTextAreaBlur(e) { // 监听到新输入的值
    this.setData({ context: e.detail.value })
  },
  bindTitle(e){
    this.setData({ title: e.detail.value })
  },
  submit(e) {//提交发布
    let { userId, title, context } = this.data
    let params = {
      userId: userId,
      title: title,
      context: context
    }
    wx.showLoading({
      title: '提交中',
      mask: true
    })
    App.HttpService.saveFeedBack(params).then(res => {
      if(res.data.code == 200){
        wx.showToast({
          title: '您的意见或建议已提交',
          icon: 'success',
          duration: 1000
        })
        setTimeout(() => {
          wx.navigateBack({
            delta: 1
          })
        }, 2000);
       
      }else{
        wx.showToast({
          title: res.data.msg,
          image: "../../assets/images/warning.png",
          duration: 2000
        })
      }
    }).catch(e => {
      wx.hideLoading()
    })
  }
})